new Vue({
  el: "#app",
  data() {
    return {
      form: {
        Data: "group_tab", //状态
        Primary_Key: "",
        Primary_Key_Name: "Group_Tab_Name", //
        isVague: true,
        page: 1, //页数
        limit: 10, //每页数据条数
      },
      formData: {},
      tableData: [{}], //表格数据
      total: 1,
      dialogForm: false,
      title: "",
      multipleSelection: [],
    };
  },
  mounted() {
    // this.getList();
    // this.getList1();
    this.getList(this.form);
  },
  methods: {
    onSerach() {
      //查询方法
      this.form.page = 1;
      this.getList(this.form);
    },
    addContract() {
      console.log("跳转");
    },
    handleSizeChange(val) {
      this.form.page = 1;
      this.form.limit = val;
      this.getList(this.form);
    },
    handleCurrentChange(val) {
      this.form.page = val;
      this.getList(this.form);
    },
    getList(data) {
      //换页方法
      let _this = this;
      $.ajax({
        headers: {
          AccessToken: $.cookie("token"), //会将数据转换为query string
        },
        type: "POST",
        // url: DomainName + "/getTableInquiryAction?token=" + $.cookie("token"),
        url: "https://service.kdddy.cn/donghui/generalBusiness/generalQueryByTableNameWithOriginal",
        // data,
        data: {
          Data: "group_tab", //表名
          Condition: "Row_Status='0'",
        },
        // complete: function (XMLHttpRequest) {
        //   _this.loading = false
        //   if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
        //     window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
        //   }
        // },
        success: function (Result) {
          console.log(Result);
          _this.tableData = Result; //将获取的数据存到表格数据中
          // _this.total = Number(Result.limit);
        },
        dataType: "json",
      });
    },
    addEnterprise() {
      window.location.href = "./Add.html";
    },
    showMember(EnterpriseInfo_SerialNumber) {
      sessionStorage.setItem(
        "EnterpriseInfo_SerialNumber",
        EnterpriseInfo_SerialNumber
      );
      window.location.href =
        "./show.html?EnterpriseInfo_SerialNumber=" +
        EnterpriseInfo_SerialNumber;
    },
    editMember(Group_Tab_SerialNumber) {
      sessionStorage.setItem("Group_Tab_SerialNumber", Group_Tab_SerialNumber);
      window.location.href =
        "./Edit.html?Group_Tab_SerialNumber=" + Group_Tab_SerialNumber;
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    deletMember(row) {
      this.$confirm("此操作将删除该系列, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          this.delete(row);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    delete(row) {
      const _this = this;
      row.Row_Status = "1";
      $.ajax({
        url: DomainName + "/getEditAction?token=" + $.cookie("token"),
        type: "POST",
        data: {
          Data: JSON.stringify({ Modify: { group_tab: [row] } }),
        },
        success: function (res) {
          _this.$message({
            type: "success",
            message: "删除成功!",
          });
          _this.getList(_this.form);
        },
        complete: function (XMLHttpRequest) {
          _this.loading = false;
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href =
              "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
      });
    },
  },
});
